package com.ydlclass.listeners;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.ApplicationListener;

public class EmailListener implements ApplicationListener<OrderEvent> {

	Logger log = LoggerFactory.getLogger(EmailListener.class);

	@Override
	public void onApplicationEvent(OrderEvent event) {
		Object source = event.getSource();
		if(source instanceof OrderDetail orderDetail) {
			// 模拟发送短信
            try {
                Thread.sleep(5000);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
			log.info("{} -> 邮件----》订单详情：{}",Thread.currentThread().getId(),orderDetail);

        }
	}
}
